package com.luzhikun.dao;

import com.luzhikun.dao.IStudentDao;
import com.luzhikun.domain.City;
import com.luzhikun.util.SqlSessionUtil;
import org.apache.ibatis.session.SqlSession;

/**
 * @Author Rookie Coder
 * @Description
 * @Date
 **/
public class StudentDaoImpl implements IStudentDao {

    /*
     * @Author liu-miss
     * @Description 根据id获取城市对象
     * @Date 20:04 2021/5/18
     * @Param [id]
     * @return com.luzhikun.domain.City
     **/
    @Override
    public City getById(String id) {

        SqlSession session= SqlSessionUtil.getSqlSession();

        City  city = session.selectOne("test1.byId", id);

        return city;
    }

    /*
     * @Author liu-miss
     * @Description 添加对象
     * @Date 20:04 2021/5/18
     * @Param
     * @return
     **/
    @Override
    public int save(City city) {

        SqlSession session=SqlSessionUtil.getSqlSession();
        System.out.println("---------");
        return session.insert("saveCity", city);

    }

    @Override
    public void delete(String id) {

        // 获取连接
        SqlSession session=SqlSessionUtil.getSqlSession();

        session.delete("test1.deleteById",id);



    }
}
